
import time
import unittest
from selenium import webdriver


from ddt import ddt,file_data

from Page.settle_Page import settle_Page
from selenium.webdriver.common.by import By

from Tools.Tools import Tools


@ddt
class SettleCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.logger = Tools().get_logger("Test.SettleCase")
    # 测试固件
    def setUp(self):
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        self.po = settle_Page(self.driver)
        self.po.login()
        dy_login = self.po.find_element((By.XPATH, '/html/body/div[1]/div[3]/div/div[2]/div/div/p[1]/span')).text
        # 登录成功断言
        self.assertEqual('龙果支付后台', dy_login)
    def tearDown(self):
        time.sleep(5)
        self.driver.quit()


    #发起结算
    @file_data(Tools.resolve_path("Data/jiesuan.yaml"))
    def test_01(self):
        try:
            self.po.jiesuan()
            time.sleep(3)
            self.po.guanli()
            time.sleep(3)
            self.po.faqi()
            time.sleep(3)
            self.po.bianhao()
            time.sleep(3)
            self.po.phone()
            time.sleep(3)
            self.po.money()
            time.sleep(3)
            self.po.shu()
            time.sleep(3)
            self.po.ti()
            dy2=self.po.find_element((By.XPATH, '/html/body/div[1]/div[2]/div[2]/div[2]/div[11]/h2/span')).text
            dy3=self.po.find_element((By.XPATH, '/html/body/div[1]/div[2]/div[2]/div[2]/div[12]/ul/li/div/a')).text
            self.logger.debug(f'断言结算管理入口：{dy2},{dy3}')
            self.logger.info('结果：成功进入结算管理入口')

        except Exception as e:
            self.logger.error(e)

if __name__ == '__main__':
    unittest.main()

